package com.suncaper.wcss.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.suncaper.wcss.model.domain.Dictionary;
import com.suncaper.wcss.mapper.DictionaryMapper;
import com.suncaper.wcss.service.DictionaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Objects;

/**
 * <p>
 * 数据字典 服务实现类
 * </p>
 *
 * @author lxp
 * @since 2021-11-12
 */
@Service
public class DictionaryServiceImpl extends ServiceImpl<DictionaryMapper, Dictionary> implements DictionaryService {

    @Override
    public String getValueByKey(String key, String type) {
        QueryWrapper<Dictionary> wrapper = new QueryWrapper<>();
        wrapper.lambda().eq(Dictionary::getItemValue,key).eq(Dictionary::getType,type);
        Dictionary dictionary = baseMapper.selectOne(wrapper);
        return Objects.isNull(dictionary)?"":dictionary.getItemName();
    }
}
